import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

type ResultOrganization = {
  success: boolean;
  data?: {
    list: Array<any>;
    totalCount: number;
  };
};

interface subAssessment {
  ver: string;
  success: boolean;
  data: string;
  cmd: string;
  status: number;
  msg: string;
}

interface ResultBigDataCase {
  status: number;
  msg: string;
  data: {
    pageIndex: number;
    pageCount: number;
    totalCount: number;
    pageSize: number;
    keyword: string;
    list: [
      {
        menuId: string;
        menuName: string;
        parentMenuId: string;
        parentMenuName: string;
        remarks: string;
        processFlow: string;
      }
    ];
  };
  success: boolean;
}

/** 删除大数据案例 */
export const DeleteBigDataCase = (params?: string) => {
  return http.request<subAssessment>(
    "get",
    baseUrlApi("/BigDataCase/DeleteBigDataCase?" + params)
  );
};

/** 获取大数据案例 */
export const GetBigDataCase = (params?: string) => {
  return http.request<ResultBigDataCase>(
    "get",
    baseUrlApi("/BigDataCase/GetAll?" + params)
  );
};

/** 添加or修改 */
export const UpdateBigDataCase = (data?: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/BigDataCase/UpdateBigDataCase"),
    {
      data
    }
  );
};

// ********************  测评管理  ***********************
interface CaseTest {
  status: number;
  msg: string;
  data: {
    pageIndex: number;
    pageCount: number;
    totalCount: number;
    pageSize: number;
    keyword: string;
    list: [
      {
        caseTestId: string;
        menuId: string;
        questionType: string;
        title: string;
        answerA: string;
        answerB: string;
        answerC: string;
        answerD: string;
        answerE: string;
        answerF: string;
        trueAnswer: string;
      }
    ];
  };
  success: boolean;
}

interface LoadCaseTest {
  status: number;
  msg: string;
  data: {
    list: [
      {
        caseTestId: string;
        menuId: string;
        parentMenuId: string;
        questionType: string;
        title: string;
        answers: [
          {
            key: string;
            value: string;
          }
        ];
        trueAnswer: string;
        userId: string;
        userAnswer: string;
      }
    ];
    isSubmit: boolean;
    questionNum: number;
  };
  success: boolean;
}

/** 查询测评管理 */
export const CaseTestGetAll = (params?: string) => {
  return http.request<CaseTest>(
    "get",
    baseUrlApi("/CaseTest/GetAll?" + params)
  );
};

/** 查询测评管理-测评题目 */
export const CaseTestLoadCaseTest = (params?: string) => {
  return http.request<LoadCaseTest>(
    "get",
    baseUrlApi("/CaseTest/LoadCaseTest?" + params)
  );
};

/** 删除测评管理 */
export const CaseTestDeleteCaseTest = (params?: string) => {
  return http.request<CaseTest>(
    "get",
    baseUrlApi("/CaseTest/DeleteCaseTest?" + params)
  );
};

/** 新增 or 修改 测评题目 */
export const UpdateCaseTest = (data?: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/CaseTest/UpdateCaseTest"),
    { data }
  );
};

/* 学生端提交测评答案 */
export const CaseTestSubmitCaseTest = (data?: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/CaseTest/SubmitCaseTest"),
    { data }
  );
};

/* 学生端重做测评 */
export const CaseTestResetCaseTest = (params?: string) => {
  return http.request<subAssessment>(
    "get",
    baseUrlApi("/CaseTest/ResetCaseTest?" + params)
  );
};

interface GetByMenuId {
  entityId: string;
  menuId: string;
  createTime: string;
  modificationTime: string;
  parentMenuId: string;
  caseName: string;
  remarks: string;
  processFlow: string;
  userId: string;
}

/**
  @param remarks 案例描述
  @param processFlow 案例流程
**/
export const BCDaaaegistGetByMenuId = (params?: string) => {
  return http.request<GetByMenuId>(
    "get",
    baseUrlApi("/BigDataCase/GetByMenuId?" + params)
  );
};
